function ctex {
# Create the tex code for the DELAY benchmark plots.
#
# $1 = first
# $2 = second
# $3 = context
# $4 = (l)ine or (c)olumn
# $5 = ms
#ms1=$(echo $5 | awk -F: '{print $1}')
#ms2=$(echo $5 | awk -F: '{print $2}')
ms1=$5
cat << EOF
Em relação ao efeito do atraso no contexto {\bf $3} comparando o desempenho de \$$1\$ e de \$$2\$ (fig. \ref{fig:delay$4cmp-$1-$2-$3}), podemos dizer:
  \begin{itemize}
    \input{chapters/resultados/delaycmp/$4-$1-$2-$3}
  \end{itemize}

  \begin{figure}[H]
  \centering
  \caption{\small Efeito do atraso na {\bf $3} \$$1/$2\$ }
  \label{fig:delay$4cmp-$1-$2-$3}
  \subfloat[0ms]{\includegraphics[angle=-90,width=0.333333333\textwidth]{images/results/jdbccmp-$1-$2-$3-ExecT}}
  \subfloat[${ms1}ms]{\includegraphics[angle=-90,width=0.333333333\textwidth]{images/results/delay$4$ms1-$1-$2-$3-ExecT}}
\end{figure}

EOF
}

function cplot2tex {
# Write the tex code for DELAY benchmark plots into the tex file.
dtype=$1
first=$2
ms=$3
suffix=$5
out=${prefix}${dtype}effect-${suffix}.tex
for context in Actualizacao Leitura; do
  for second in $4; do
    ctex $first $second $context $dtype $ms >> $out
  done
done
}

prefix="images/results/"
for dtype in l c; do
  for cmp in jdbccmp wjdbccmp; do
    rm -rf ${prefix}${dtype}effect-${cmp}.tex
  done
done

a=(CJDBC_I CJDBC_S WJDBC)
cplot2tex c JDBC 1 "${a[*]}" jdbccmp
cplot2tex l JDBC 8 "${a[*]}" jdbccmp

a=(CJDBC_I CJDBC_S)
cplot2tex c WJDBC 1 "${a[*]}" wjdbccmp
cplot2tex l WJDBC 8 "${a[*]}" wjdbccmp
